package com.hsd.znsh.repository;

import com.hsd.znsh.entity.Host;
import com.hsd.znsh.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/*
 * @auther: wangjiacai
 *
 * @create: 2018-04-23 11:54:50
 */
public interface HostRepository extends JpaRepository<Host,Integer> {

    List<Host> findByDeleted(Integer deleted);

    List<Host> findByManagerIdAndDeleted(Integer managerId,Integer deleted);

    List<Host> findByIdIn(List<Integer> id);

    List<Host> findByHostNameLikeAndDeleted(String hostName,Integer deleted);

    List<Host> findByManagerIdAndHostNameLikeAndDeleted(Integer managerId,String hostName,Integer deleted);


    @Query("select hostSn from Host where deleted=0 and managerId = ?1")
    List<String> findHostSnListByManagerId(Integer managerId);

    @Query("select id from Host where deleted=0 and managerId = ?1")
    List<Integer> findIdListByManagerId(Integer managerId);


    @Query("select hostSn from Host where deleted=0 and id in (?1)")
    List<String> findHostSnListByIdIn(List<Integer> id);

    Host findByHostSn(String hostSn);
}

